<?php

class Model_bleu extends CI_Model {

	public function hitung_bleu($hasil){
		//print_r($hasil);
		foreach($hasil['no'] as $no_jawaban){
			$BLEU['no'][$no_jawaban] = $no_jawaban;
			$BLEU['error_digit']	 = $hasil['error_digit'];
			foreach($hasil['no_kunci'] as $no_kunci){
				$BLEU['skor']					 = $hasil['skor'];
				$BLEU['no_kunci'][$no_kunci]	 = $no_kunci;
				$BLEU['BP_bleu'][$no_kunci][$no_jawaban] = $this->BP_bleu_validation($hasil[$no_kunci]['kunci']['jumlah'], $hasil[$no_jawaban]['jawaban']['jumlah'], $hasil['e']);
				$BLEU['BLEU'][$no_kunci][$no_jawaban]	 = round($BLEU['BP_bleu'][$no_kunci][$no_jawaban] * pow($hasil['e'], ((1/4) * $hasil['log'][$no_kunci][$no_jawaban])),$hasil['error_digit']);
			}
		}
		return $BLEU;
	}
	
	public function BP_bleu_validation($kunci, $jawaban, $e){
		if($kunci>$jawaban){
			$BP_bleu = 1;
		}
		else{
			$BP_bleu = pow($e, (1 - ($jawaban/$kunci)));
		}
		return $BP_bleu;
	}

}